<template>
  <el-dialog class="el-dialog" title="分配部门" v-model="dialogFormVisible" :append-to-body="append">
    <el-form>
      <el-select v-model="departments.id" placeholder="请选择分配部门">
        <el-option label="暂不分配" :value="null"></el-option>
        <template v-for="department in departments" :key="department.id">
          <el-option :label="department.name" :value="department.id"></el-option>
        </template>
      </el-select>
    </el-form>
    <div slot="footer" class="dialog-footer" style="margin-top: 10px">
      <el-button @click="dialogFormVisible = false">取 消</el-button>
      <el-button type="primary" @click="submitForm()">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
import instanceToken from "@/utlis/tokenIdentify.js";
export default {
  name: 'DistributionDialog',
  components: {},
  data() {
    return {
      dialogFormVisible: false,
      append: true,
      id:'',
      departments:[],
      companyUser:{},
      formLabelWidth: '120px'
    };
  },
  created() {},
  methods: {
    selectDepartment(id) {
      this.id = id;
      instanceToken.get("/apply/leader/selectDepartment/"+id).then(res =>{
        this.departments = res.data.data;
      })
    },
    submitForm() {
      instanceToken.get("/apply/leader/assignment",{params:{
          id:this.id,
          departmentId:this.departments.id
        }}).then(res =>{
        this.$message({
          message: '修改成功',
          type: 'success'
        });
        this.close();
        window.location.reload()
      })
    },
    show() {
      this.dialogFormVisible = true;
    },
    close() {
      this.dialogFormVisible = false;
    }
  },

}
</script>

<style>
.el-dialog {
  width: 500px;
}
</style>
